package com.org.javabody.lambda.List;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by Administrator on 2017-01-18.
 */
public class ListDemo {

    public static final List<String> LIST = new ArrayList<String>(Arrays.asList("100","200","300","400","500"));

    public static void beforeJdk8(){
        for (String l : LIST) {
            System.out.print(l+" ");
        }
    }

    public static void afterJdk8(){
        System.out.println("\nMethod one:");
        LIST.forEach(l -> System.out.print(l+" "));

        // Even better use Method reference feature of Java 8
        // method reference is denoted by :: (double colon) operator
        // looks similar to score resolution operator of C++
        System.out.println("\nMethod two:");
        LIST.forEach(System.out::println);

    }

    public static void main(String[] args) {
        ListDemo.beforeJdk8();
        ListDemo.afterJdk8();
        System.exit(0);
    }
}
